"""
1.定位到滑块
2.计算滑块框的宽度
3.将滑块向右拖动滑块宽度的距离
使用鼠标事件 drag_and_drop_by_offset
"""
import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

wd = webdriver.Chrome()
wd.maximize_window()
wd.get("https://passport.ctrip.com/user/reg/home")
wd.find_element(By.LINK_TEXT, "同意并继续").click()
# 定位滑块
slide = wd.find_element(By.XPATH,'//div[@id="slideCode"]/div[1]/div[2]')
# 获取整个滑块框
ele = wd.find_element(By.ID,'slideCode')
# 鼠标事件
time.sleep(1)
ActionChains(wd).drag_and_drop_by_offset(slide,ele.size["width"],0).perform()
time.sleep(1)